import {
  createPinia,
  defineStore
} from "pinia";
// 引入持久化插件
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
// 实例化pinia
export const store = createPinia();
// 使用持久化存储插件
store.use(piniaPluginPersistedstate);

// 系统统一存储
export const useAppStore = defineStore("app", {
  state: () => ({
    appName: "",
    baseUrl: "http://222.65.16.33:2424/",
    // baseUrl: "http://192.168.1.102:2424/",
    userInfo: {},
    userLoginInfo: {},
    projectInfo: {},
    projectList: [],
    BdataPageName: "人员管理",
    CworkbenchIndex: 0
  }),
  actions: {
    setAppName(data) {
      this.appName = data;
    },
    setUserLoginInfo(data) {
      this.userLoginInfo = data;
    },
    setUserInfo(data) {
      this.userInfo = data;
    },
    setProjectInfo(data) {
      this.projectInfo = data;
    },
    setProjectList(data) {
      this.projectList = data;
    },
    setBdataPageName(data) {
      this.BdataPageName = data;
    },
    setCworkbenchIndex(data) {
      this.CworkbenchIndex = data;
    },
  },
  persist: {
    storage: localStorage, //default localStorage
  },
});